<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
  <!-- Content Header (Page header) -->
  <section class="content-header">
    <h1>
      数据库上线历史
      <small></small>
    </h1>
    <ol class="breadcrumb">
      <li><a href="#"><i class="fa fa-dashboard"></i> Level</a></li>
      <li class="active">Here</li>
    </ol>
  </section>
  <!-- Main content -->
  <section class="content">

    <div class="row">
      <div class="col-xs-12">

        <div class="box">
          <div class="box-body">
            <table id="data_table" class="table table-bordered table-striped">
              <thead>
              <tr>
                <th>编号</th>
                <th>数据库名称</th>
                <th>用途</th>
                <th>提交人</th>
                <th>状态</th>
                <th>审核人</th>
                <th>执行时间</th>
                <th>详情</th>
              </tr>
              </thead>
              <tbody>
              <% @sql_order_his.each do |sql_order_history| %>
                  <tr>
                    <td><%= sql_order_history.id %></td>
                    <td><%= sql_order_history.database.dbname %>-<%= sql_order_history.database.env %></td>
                    <td><%= sql_order_history.title[0..29] %></td>
                    <td><%= sql_order_history.user.username %></td>
                    <td><%=  I18n.t(sql_order_history.status) %></td>
                    <td><%= sql_order_history.auditor %></td>
                    <% if sql_order_history.status == 'audited' || sql_order_history.status == 'inqueue' || sql_order_history.status == 'executing' || sql_order_history.status == 'fileupload'%>
                        <td>预计<%= sql_order_history.schedule.try(:strftime,'%H:%M:%S') %></td>
                    <%end%>
                    <% if sql_order_history.status == 'submitted' || sql_order_history.status == 'rejected' || sql_order_history.status == 'ready' || sql_order_history.status == 'vetoed' || sql_order_history.status == 'failed'|| sql_order_history.status == 'incomplete' || sql_order_history.status == 'succeeded' || sql_order_history.status == 'cancelled' %>
                        <td><%= sql_order_history.exec_time.try(:strftime,'%H:%M:%S') %></td>
                    <%end%>

                    <td>
                      <div class="btn-group">
                        <button type="button" class="btn btn-info table_btn" onclick=location.href=('/sql_history/<%= sql_order_history.id %>')>详情</button>
                      </div>
                    </td>
                  </tr>
              <% end %>
              </tbody>
            </table>
          </div>
          <!-- /.box-body -->
        </div>
        <!-- /.box -->
      </div>
      <!-- /.col -->
    </div>
    <!-- /.row -->
  </section>
  <!-- /.content -->
</div><!-- /.content-wrapper -->

<script type="text/javascript">
  $(function () {
    //列表排序脚本
    $("#data_table").dataTable({
      "bSort": false
    });
  })
</script>